<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/head::head('','/css/bootstrap/select/bootstrap-select.min.css','/js/laydate/laydate.js,/js/jquery-validate/jquery.validate.min.js,/js/bootstrap/select/bootstrap-select.min.js,/js/bootstrap/select/defaults-zh_CN.min.js')">
</head>
<script th:inline="javascript">
    /*<![CDATA[*/

    var basePath = /*[[${#httpServletRequest.getScheme() + "://" + #httpServletRequest.getServerName() + ":" + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]]*/ 'basepath';

    function ok(){

        var valiReuslt = $("#dataForm").valid();

        if(!valiReuslt){
            return false;
        }
        var formData = $("#dataForm").serialize();
        var url = basePath + "/lims/role/updRole";
        $.post({
            url:url,
            data:formData,
            dataType:"json",
            success:function(data){
                if(data.code == 0){
                    parent.spop({
                        template: data.msg,
                        position  : 'top-center',
                        style: 'success',
                        autoclose: 2000
                    });
                    closeModal();
                    parent.openMainFrame("/role/roleList");
                }else{
                    parent.spop({
                        template: '修改失败',
                        position  : 'top-center',
                        style: 'error',
                        autoclose: 3000
                    });
                }
            }
        });


    }

    function closeModal(){
        parent.closeModal();

    }

    $(function(){
        $("#dataForm").validate({
            rules:{
                roleName:"required"
            },
            messages:{
                roleName:"请输入角色名称"
            }
        });

    });



    /*]]>*/
</script>
<!--layDate日期组件初始化-->
<script>
    lay('#version').html('-v'+ laydate.v);

    //执行一个laydate实例
    laydate.render({
        elem: '#birthday' //指定元素
    });
</script>



<body>
    <div class="container">

        <form th:id="dataForm" class="form-control" style="width: 107%;margin-left: -15px;">
            <input type="hidden" th:name="roleId" th:value="${role.roleId}">
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text">角色名称</span>
                </div>
                <input type="text" th:id="roleName" th:name="roleName" th:value="${role.roleName}" class="form-control" autocomplete="off">
            </div>
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text">角色描述</span>
                </div>
                <textarea type="text" th:id="roleDesc" th:name="roleDesc" th:text="${role.roleDesc}" class="form-control" autocomplete="off"></textarea>
            </div>
            <div class="input-group mb-3">
                <div class="input-group-prepend">
                    <span class="input-group-text">是否启用</span>
                </div>
                <div class="RadioStyle">
                    <div class="Block PaddingL" style="margin-left: 10px;">
                        <input type="radio" name="available" id="status2" th:value="1" th:checked="${role.available}?'checked'"/>
                        <label for="status2">启用</label>
                        <input type="radio" name="available"  id="status1" value="0" th:checked="${! role.available}?'checked'"/>
                        <label for="status1"  style="margin-left: 10px;">不启用</label>
                    </div>
                </div>
            </div>
            <div th:align="right">
                <button type="button" th:onclick="'javascript:ok()'" th:name="submitBtn"  class="btn btn-primary">修改</button>
                <button type="reset" class="btn btn-warning">重置</button>
                <button type="button" th:onclick="'javascript:closeModal()'" class="btn btn-secondary">关闭</button>
            </div>

        </form>
    </div>

</body>



</html>